import { createRouter, createWebHistory ,createWebHashHistory} from 'vue-router'
// 引入一个组件
import HomeView from '../views/HomeView.vue'

const routes = [
  {
    path: '/',
    name: 'home',
    // 使用组件
    component: HomeView
  },
  {
    path: '/about',//
    name: 'about',
    // 懒加载
    // 当访问的时候才会去加载这个组件  不访问不加载
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },

  {
    path:"/login",
    name:"login",
    component: ()=>import('../views/login.vue')

  },
  {
    path:"/main",
    name:"main",
    component: ()=>import('../views/main.vue'),
    children:[
      {
        path:"/stu",
        name:"stu",
        component: ()=>import('../views/stu.vue')

      },
      {
        path:"/role",
        name:"role",
        component: ()=>import('../views/role.vue')

      },
      {
        path:"/user",
        name:"user",
        component: ()=>import('../views/user.vue')

      },

    ]

  },
  {
    path:'/:a*',
    component: ()=>import("../views/404.vue") // 使用import方法引入组件
  }

]

const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes
})

export default router
